#ifndef __XML_HH_
#define __XML_HH_

typedef enum _xml_state
{
    XML_ERROR,
    XML_NONE,
    XML_NBEGIN,
    XML_NEND,
    XML_COMMENT,
    XML_DATA,
    XML_TAG,
    XML_NFULL
}xml_state;

typedef struct _x_str{
    char *text;
    int len;
}x_str,*px_str;

typedef struct _x_attri{
    x_str name;                //attribute name
    x_str value;               //attribute value
    struct _x_attri *sibling;  //sibling attribute
}x_attri,*px_attri;

typedef struct _x_node{
    x_str name;
    x_str value;
    px_attri attri_list;
    struct _x_node *parent;
    struct _x_node *sibling;
    struct _x_node *child;
}x_node,*px_node;

typedef struct _x_tree{
    x_node *root;
    x_node *cur_node;
    x_node *pre_node;
    int count;
    int cur_status;
}x_tree;

extern x_node *xml_parse_read(char *xmlbuf,int xmlsize);
extern char *xml_get_attribyname(x_node *node,char *name);
extern x_node *xml_get_nodebyname(x_node *node,char *name);
extern x_node *xml_get_parent(x_node *parent);
extern x_node *xml_get_subnode(x_node *parent);
extern char *xml_get_node_name(x_node *node);
#endif